﻿using System;
using System.ComponentModel;

namespace Jerry.DroidBuilder.ThemeEditor
{
    public class LayoutInfoPropertyDescriptor : PropertyDescriptor
    {
        private string _key;
        private LayoutInfo _instance;

        public LayoutInfoPropertyDescriptor(LayoutInfo instance, string key) :
            base(key, null)
        {
            _key = key;
            _instance = instance;
        }

        public override bool CanResetValue(object component)
        {
            return false;
        }

        public override Type ComponentType
        {
            get { return typeof(LayoutInfo); }
        }

        public override object GetValue(object component)
        {
            return (component as LayoutInfo).GetValue(_key);
        }

        public override bool IsReadOnly
        {
            get { return false; }
        }

        public override Type PropertyType
        {
            get { return typeof(string); }
        }

        public override void ResetValue(object component)
        {
            // (component as LayoutElement).SetValue(_key, null);
        }

        public override void SetValue(object component, object value)
        {
            (component as LayoutInfo).SetValue(_key, value as string);
        }

        public override bool ShouldSerializeValue(object component)
        {
            return false;
        }
    }
}
